package com.nuoniu.sibanyun.controller.crm.call;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.crm.call.CrmCallTask;
import com.nuoniu.sibanyun.entity.crm.call.dto.CrmCallTaskDto;
import com.nuoniu.sibanyun.service.crm.call.ICrmCallTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 客户管理-外呼任务管理 前端控制器
 * </p>
 *
 * @author 白强
 * @since 2022-02-28
 */
@RestController
@RequestMapping("/crm/callTask")
@Api(tags = "客户管理-外呼任务管理")
public class CrmCallTaskController extends BaseController {

    @Autowired
    private ICrmCallTaskService taskService;

    @PostMapping("pageList")
    @ApiOperation(value = "分页查询 外呼任务")
    public HttpResult pageList(@RequestBody CrmCallTaskDto crmCallTaskDto) {
        return HttpResult.ok(taskService.pageList(crmCallTaskDto));
    }

    @PostMapping("saveTask")
    @ApiOperation(value = "保存 外呼任务")
    public HttpResult saveTask(@RequestBody CrmCallTask crmCallTask){
        taskService.saveTask(crmCallTask);
        return HttpResult.ok();
    }

    @GetMapping("detail")
    @ApiOperation(value = "查询详情")
    public HttpResult detail(Long id){
        return HttpResult.ok(taskService.detailById(id));
    }

    @PostMapping("batchDelete")
    @ApiOperation(value = "批量删除 外呼任务")
    public HttpResult batchDelete(@RequestBody List<Long> ids){
        taskService.batchDelete(ids);
        return HttpResult.ok();
    }

    @PostMapping("closeTask")
    @ApiOperation(value = "批量关闭 外呼任务")
    public HttpResult closeTask(@RequestBody List<Long> ids){
        taskService.closeTask(ids);
        return HttpResult.ok();
    }

}
